package com.cssy.yd.basic.dao.impl;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import com.cssy.yd.basic.dao.BasicCompanytypeDAO;
import com.cssy.yd.basic.entity.BasicCompanyDO;
import com.cssy.yd.basic.entity.BasicCompanytypeDO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2013-04-24
 */
public class BasicCompanytypeDAOImpl extends SqlMapClientDaoSupport implements BasicCompanytypeDAO {

    /**
     * 插入数据
     * @param basicCompanytypeDO
     * @return 插入数据的主键
     */
    public void insertBasicCompanytypeDO(BasicCompanytypeDO basicCompanytypeDO) throws DataAccessException {
        getSqlMapClientTemplate().insert("BasicCompanytype.insert", basicCompanytypeDO);
    }

    /**
     * 统计记录数
     * @param basicCompanytypeDO
     * @return 查出的记录数
     */
    public Integer countBasicCompanytypeDOByExample(BasicCompanytypeDO basicCompanytypeDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicCompanytype.countByDOExample", basicCompanytypeDO);
        return count;
    }

    /**
     * 更新记录
     * @param basicCompanyDO
     * @return 受影响的行数
     */
    public Integer updateBasicCompanyDO(BasicCompanytypeDO basicCompanyDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("BasicCompanytype.update", basicCompanyDO);
        return result;
    }
    
    /**
     * 获取对象列表
     * @param basicCompanytypeDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<BasicCompanytypeDO> findListByExample(BasicCompanytypeDO basicCompanytypeDO) throws DataAccessException {
        List<BasicCompanytypeDO> list = getSqlMapClientTemplate().queryForList("BasicCompanytype.findListByDO", basicCompanytypeDO);
        return list;
    }

    /**
     * 根据主键获取basicCompanyDO
     * @param id
     * @return basicCompanyDO
     */
    public BasicCompanytypeDO findBasicCompanyDOByPrimaryKey(String id) throws DataAccessException {
    	BasicCompanytypeDO basicCompanyDO = (BasicCompanytypeDO) getSqlMapClientTemplate().queryForObject("BasicCompanytype.findByPrimaryKey", id);
        return basicCompanyDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteBasicCompanyDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("BasicCompanytype_ex.deleteById", id);
        return rows;
    }
    
    @Override
   	public List<BasicCompanytypeDO> find(SearchConditions scs)
   			throws DataAccessException {
   		System.out.println(scs.getPrefix());
   		List<BasicCompanytypeDO> list = getSqlMapClientTemplate().queryForList("BasicCompanytype_ex.find", scs);
   		   return list;
   	}

   	@Override
   	public Integer count(SearchConditions scs) throws DataAccessException {		
   		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicCompanytype_ex.count", scs);
   	      return count;
   	}
}